package cc.comac.mom.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.EquipParamItemService;
import cc.comac.mom.bean.EquipParamItem;
import cc.comac.mom.datahandlers.entity.EquipParamItemDataHandler;
import cc.comac.mom.util.ResultBean;

@Service
@RestController
public class EquipParamItemServiceImpl implements EquipParamItemService {
	@Autowired
	private EquipParamItemDataHandler equipParamItemDataHandler;

	@Override
	public ResultBean insert(@RequestBody EquipParamItem equipParamItem) {
		ResultBean resultBean = new ResultBean(true);
		int insert = equipParamItemDataHandler.insert(equipParamItem);
		resultBean.setObject(insert);
		return resultBean;
	}

	@Override
	public ResultBean update(@RequestBody EquipParamItem equipParamItem) {
		ResultBean resultBean = new ResultBean(true);
		int update = equipParamItemDataHandler.update(equipParamItem);
		resultBean.setObject(update);
		return resultBean;
	}

	@Override
	public ResultBean batchDelete(@RequestBody List<EquipParamItem> equipParamItem) {
		ResultBean resultBean = new ResultBean(true);
		int batchDelete = equipParamItemDataHandler.batchDelete(equipParamItem);
		resultBean.setObject(batchDelete);
		return resultBean;
	}

	@Override
	public ResultBean selectAllByPage(@RequestBody EquipParamItem equipParamItem) {
		ResultBean resultBean = new ResultBean(true);
		EquipParamItem selectAllByPage = equipParamItemDataHandler.selectAllByPage(equipParamItem);
		if(selectAllByPage==null || selectAllByPage.getEntityList().size()<1) {
			selectAllByPage = null;
		}
		resultBean.setObject(selectAllByPage);
		return resultBean;
	}


	@Override
	public ResultBean returnSelectAllByParamName(@RequestBody EquipParamItem equipParamItem) {
		ResultBean resultBean = new ResultBean(true);
		EquipParamItem info = equipParamItemDataHandler.returnSelectAllByParamName(equipParamItem);
		resultBean.setObject(info);
		return resultBean;
	}

	@Override
	public ResultBean returnSelectAllByParamNameandParamItemName(@RequestBody EquipParamItem equipParamItem) {
		ResultBean resultBean = new ResultBean(true);
		EquipParamItem info = equipParamItemDataHandler.returnSelectAllByParamNameandParamItemName(equipParamItem);
		resultBean.setObject(info);
		return resultBean;
	}

}
